package com.tnt.webpageauthorization.demo;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author zhuangxl
 * @Date 2021-01-18 15:06
 */
@Slf4j
public class Test {

    public static void main(String[] args)throws Exception {

        // 静默授权获取用户的openid
        String redirect_uri = "http://pthniq.natappfree.cc/webpage/authorization/snsapi_base";
        String scope = "snsapi_base";
        //额外参数
        String state = "123";

        String snsapi_base_url = WechatUtil.getWebPageAuthorizationUrl(redirect_uri, scope, state);

        log.info(snsapi_base_url);

        // 手动授权获取用户的基本信息
        redirect_uri = "http://pthniq.natappfree.cc/webpage/authorization/snsapi_userinfo";
        scope = "snsapi_userinfo";
        //额外参数
        state = "456";

        String snsapi_userinfo_url = WechatUtil.getWebPageAuthorizationUrl(redirect_uri, scope, state);
        log.info(snsapi_userinfo_url);
    }
}
